const express = require('express');
      bodyParser = require('body-parser')
      router = express.Router();

app.use(bodyParser.urlencoded({extended:true}))

//回答页面渲染
var askId
router.get('/ans/:thisId',(req,res) => {
  // console.log(req.params.thisId)
  askId = req.params.thisId
  res.clearCookie('askId')
  res.send({init:666})
})

router.get('/Answer',(req,res) => {
  res.cookie('askId',askId)
  res.render('answer',{
    title:'回答'
  })
})

//回答部分
app.post('/answer',(req,res) => {
  var name = req.cookies.username
  req.body.name = name
  var time = new Date()
  req.body.time = time
  console.log(req.body)
  var ans = new Answer(req.body)
  
  ans.save(function(err,data){
      send(res,'success','登陆成功..')
    })
})

module.exports = router